package com.ttsx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttsx.mapper.ProductDetailMapper;
import com.ttsx.pojo.entity.ProductDetail;
import com.ttsx.service.ProductDetailService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
* @author lucky
* @description 针对表【ttsx_product_detail(产品详情表)】的数据库操作Service实现
* @createDate 2025-03-01 17:41:06
*/
@Service
public class ProductDetailServiceImpl extends ServiceImpl<ProductDetailMapper, ProductDetail>
    implements ProductDetailService{

    @Override
    public List<ProductDetail> getByProductId(Long productId) {
        LambdaQueryWrapper<ProductDetail> lqw = new LambdaQueryWrapper<>();
        lqw.eq(ProductDetail::getProductId, productId);

        return baseMapper.selectList(lqw);
    }

    @CacheEvict(value = "category", allEntries = true)  // 清空缓存
    @Override
    public boolean save(ProductDetail entity) {
        return super.save(entity);
    }

    @CacheEvict(value = "category", allEntries = true)  // 清空缓存
    @Override
    public boolean updateById(ProductDetail entity) {
        return super.updateById(entity);
    }

    @CacheEvict(value = "category", allEntries = true)  // 清空缓存
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }
}




